package com.example.pinkcat.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.PagerTabStrip;
import androidx.viewpager.widget.ViewPager;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;


import com.example.pinkcat.R;
import com.example.pinkcat.activity.adapter.FFP_viewpager_adapter;

import java.util.ArrayList;
import java.util.Objects;

public class FansFollowPage extends AppCompatActivity {

    Context context =this;
    ViewPager viewPager;//viewpager组件
    PagerTabStrip pagerTab;  //PagerTabStrip组件
    ArrayList<View> views=new ArrayList<>();

    boolean isFansPage=false;

    String up_id;
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        if (newConfig.fontScale != 1)//非默认值
            getResources();
        super.onConfigurationChanged(newConfig);
    }

    @Override
    public Resources getResources() {
        Resources res = super.getResources();
        if (res.getConfiguration().fontScale != 1) {//非默认值
            Configuration newConfig = new Configuration();
            newConfig.setToDefaults();//设置默认
            res.updateConfiguration(newConfig, res.getDisplayMetrics());
        }
        return res;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Objects.requireNonNull(getSupportActionBar()).hide();//去掉标题栏
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//                WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
        setContentView(R.layout.activity_fans_follow_page);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }//深色信息栏

        Intent intent=getIntent();
        if (intent!=null){
            isFansPage=intent.getBooleanExtra("isFansPage",false);
            up_id=intent.getStringExtra("up_id");
        }

        viewPager=findViewById(R.id.friends_viewpager);
        pagerTab=findViewById(R.id.friends_viewpager_Table);

        //返回监听
        findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });


        //初始化viewpager
        SetViews();
        FFP_viewpager_adapter video_viewpager_adapter=new FFP_viewpager_adapter(new String[]{"~关注~", "~粉丝~"},views,context,up_id);
        viewPager.setAdapter(video_viewpager_adapter);
        pagerTab.setTabIndicatorColor(getResources().getColor(R.color.pink));//标题栏指示器的颜色
        //pagerTab.setTextColor(getResources().getColor(R.color.pink));  //设置标题字体颜色
        pagerTab.setTextSpacing(20);
        pagerTab.setTextSize(1, 16);  //设置标题字体大小
        pagerTab.setDrawFullUnderline(false);//下横线
        if (isFansPage){
            viewPager.setCurrentItem(1);//设定默认选中的
        }
        else {
            viewPager.setCurrentItem(0);//设定默认选中的
        }

    }

    public void SetViews(){
        views.add(getLayoutInflater().inflate(R.layout.friends_follow_fans, null));
        views.add(getLayoutInflater().inflate(R.layout.friends_follow_fans, null));
    }
}